import React, { Component } from 'react';
import moment from 'moment'
import { connect } from 'react-redux'
import { Modal, Form, Input, DatePicker } from 'antd';
const FormItem = Form.Item;

class EntryModal extends Component {

    constructor(props) {
        super(props);
    }

    okHandler = () => {
        const { onOk } = this.props;
        this.props.form.validateFields((err, values) => {
         if (!err) {
            onOk(values);
         }
        });
    }; 


    render() {
        const { getFieldDecorator } = this.props.form;  

        const formItemLayout = {
            labelCol: { span: 6 },
            wrapperCol: { span: 16 },
        };  

        return (
            <span>
                <Modal
                    maskClosable= {this.props.maskClosable}
                    confirmLoading= {this.props.confirmLoading}
                    title={this.props.title}
                    visible={this.props.visible}
                    onOk={this.okHandler}
                    onCancel={this.props.onCancel}
                    key={this.props.newKey}
                >
                    <Form layout='horizontal' onSubmit={this.okHandler}>
                         <FormItem style={{marginBottom:'0px'}}>
                            {getFieldDecorator('id',{initialValue:this.props.itemId})(
                            <Input type="hidden"/>
                            )}
                        </FormItem>
                        <FormItem
                            {...formItemLayout}
                            label="进入时间"
                            hasFeedback
                        >
                            {
                            getFieldDecorator('entryTime', {
                                rules: [{
                                required: true, message: '请输入人员进入时间',
                                }]
                            })(<DatePicker showTime format="YYYY-MM-DD HH:mm" placeholder="进入时间" />)
                            }
                        </FormItem>
                    </Form>
                </Modal>
            </span>
        );
    }
}   

export default Form.create()(EntryModal)